package codechicken.wirelessredstone.core;

import net.minecraft.src.TileEntity;

public class FreqBlockCoord implements Comparable<FreqBlockCoord>
{
	public FreqBlockCoord(int x, int y, int z, int freq)
	{
		this.x = x;
		this.y = y;
		this.z = z;
		this.freq = freq;
	}

	public FreqBlockCoord(ITileWireless itile)
	{
		TileEntity tile = (TileEntity)itile;
		x = tile.xCoord;
		y = tile.yCoord;
		z = tile.zCoord;
		freq = itile.getFreq();
	}
	
	public FreqBlockCoord(BlockCoord node, int freq)
	{
		x = node.x;
		y = node.y;
		z = node.z;
		this.freq = freq;
	}

	public int compareTo(FreqBlockCoord node2)
	{
		if(freq == node2.freq)
		{
			if(x == node2.x)
			{
				if(z == node2.z)
				{
					if(y == node2.y)
					{
						return 0;
					}
					else
					{
						return y < node2.y ? -1 : 1;
					}
				}
				else
				{
					return z < node2.z ? -1 : 1;
				}
			}
			else
			{
				return x < node2.x ? -1 : 1;
			}
		}
		else
		{
			return freq < node2.freq ? -1 : 1;
		}
	}
	
	public String toString()
	{
		return "["+x+","+y+","+z+" on "+freq+"]";
	}
	
	public int x;
	public int y;
	public int z;
	public int freq;
}
